home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hottest 6
/
Hottest 6 (1996)(PDSoft)[!].iso
/
software
/
emulators
/
tap3zxs
/
source
/
tap3zxs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-11-24
|
3KB
|
113 lines
/* Convert .TAP file from stdin to .ZXS file to stdout.
stderr for report/list
(C)1995 @BABOLO V.M 1.2 29.06.95
My e-mail address is: babolo@relcom.net or babolo@kiae.su
My web is: http://relcom.eu.net/zx/
Help me to collect all ZX software
*/
/* MSDOS version created 8/7/95 B.Baylis@cs.ucl.ac.uk */
/* This file was modified when I created the MSDOS version
stdin and stdout are no longer used, the .TAP input is first parameter on
command line, and the .ZXS output the second parameter.
This was done so I use could the convertors with batch files and aliases
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#define TF stderr
/*#define IF stdin*/
/*#define OF stdout*/
#define DB(h,l) ((((h)&0377)<<8)+((l)&0377))
#include "cnvout.h"
FILE * OF;
FILE * IF;
int byt, blk, nu, i;
char x;
static void pt(c)
int c;
{ c&=0377;
fputc(c,OF);
x^=c;
if(((byt++)&~0777)!=0){ blk++; byt&=0777;};
};
static int gc()
{ int c;
c=fgetc(IF);
if(c==EOF){fprintf(TF," length underflow\n"); exit(1); };
return(c&0377);
};
int main(argc, argv) int argc; char *argv[];
{ char hd[19];
int hdp, b, b0, b1;
long l;
IF=fopen(argv[1],"rb");
OF=fopen(argv[2],"wb");
for(nu=0,byt=0,blk=0
; EOF!=(b0=getc(IF))
&& EOF!=(b1=getc(IF))
&& (0!=(l=DB(b1,b0)))
;)
{ dp(nu++,3);
if((l+5)>0177777)
{ fprintf(TF," length overflow\n"); exit(1);}
else
{ pt(l+5); pt ((l+5)>>8);
p2e(l-2);
pt(0); p1e(0); pt(0); p1e(0); pt(0); p1e(0);
for(x=0,i=0;((hdp=i)<19)&&(i!=l);i++)pt(hd[i]=b=gc());
if((hdp>1)&&(hd[0]==0))
{ p1h(hd[1]); pl2("%c",042);
for(i=2;(i<12)&&(i<hdp);i++) pcc(hd[i]);
pl2("%c",042);
for(i=hdp;i<12;i++) bp(1);
if(hdp>=12)p2e((hdp==12)?hd[12]:DB(hd[13],hd[12]));else bp(6);
if(hdp>=14)p2e((hdp==14)?hd[14]:DB(hd[15],hd[14]));else bp(6);
if(hdp>=16)p2e((hdp==16)?hd[16]:DB(hd[17],hd[16]));else bp(6);
}
else{
p1c(hd[0]); pl1("=");
for(i=1;(i<11)&&(i<hdp);i++) pcc(hd[i]);
pl1("= ");
for(i=(hdp>0)?hdp:1;i<11;i++) bp(1);
}; };
for(i=hdp;i!=l;i++)pt(b=gc());
p1e(x); bp(1);
ee: op(blk,4); pl1("/"); op(byt,3); pl1("\n");
};
if(b0!=EOF)
{ dp(nu++,3);
if(b0!=0){ fprintf(TF," Illegal end\n"); exit(1);};
if(b1==EOF) pl1(" Zero one");
else
{ for(i=2;EOF!=(b=getc(IF));i++)b0|=b;
p2e(i);
if(b0==0)pl1(" Zeros");
else pl1(" Scrap");
};
pl1("\n");
};
exit(0);
}